package com.hl.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.entity.CourseMark;
import com.hl.sfzy.mapper.CourseMarkMapper;
import com.hl.sfzy.service.CourseMarkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseMarkServiceImpl implements CourseMarkService {
    @Autowired
    private CourseMarkMapper courseMarkMapper;
    @Override
    public int add(CourseMark courseMark) {
        return courseMarkMapper.insert(courseMark);
    }

    @Override
    public int remove(Long courseMarkId) {
        return courseMarkMapper.deleteByPrimaryKey(courseMarkId);
    }

    @Override
    public int edit(CourseMark courseMark) {
        return courseMarkMapper.updateByPrimaryKey(courseMark);
    }

    @Override
    public CourseMark findById(Long courseMarkId) {
        return courseMarkMapper.selectByPrimaryKey(courseMarkId);
    }

    @Override
    public PageInfo<CourseMark> findAll(Integer pageNum, Integer pageSize, CourseMark courseMark) {
        PageHelper.startPage(pageNum,pageSize);
        List<CourseMark> list = courseMarkMapper.selectAll(courseMark);
        return new PageInfo<>(list);
    }

    @Override
    public int removeBatch(List<Long> ids) {
        return courseMarkMapper.deleteBatch(ids);
    }
}
